package apis

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"zorm-learn/app/query/service"
	"zorm-learn/app/util"
)

var Routers = make([]func(*gin.RouterGroup), 0)

func init() {
	Routers = append(Routers, func(group *gin.RouterGroup) {
		group.GET("/query", queryById)
	})
}

// queryById @Summary 根据ID查询
// @Description 根据ID查询
// @Tags 用户
// @Accept x-www-form-urlencoded
// @Produce json
// @Router /api/v1/query [get]
// @Param id query int true "主键"
func queryById(context *gin.Context) {
	id, _ := context.GetQuery("id")
	data, err := service.FindSysCasbinRuleStructById(context, id)
	if err != nil {

		context.JSON(http.StatusInternalServerError, gin.H{"msg": err.Error()})
		return
	}
	util.MainCtx.Logger.Info("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ")
	context.JSON(http.StatusOK, util.Success(data))
}
